﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace ProjScan.Submodules.Shader_Analysis
{
	// Token: 0x02000182 RID: 386
	internal class ShaderPassKeyManager
	{
		// Token: 0x06000D63 RID: 3427 RVA: 0x00006D61 File Offset: 0x00004F61
		public void AddShaderPass(SAShaderPass sashaderPass_0)
		{
			this.shaderPassList.Add(sashaderPass_0);
			this.ProcessShaderPassList();
		}

		// Token: 0x06000D64 RID: 3428 RVA: 0x0003B860 File Offset: 0x00039A60
		public void AddKeywordsByName(string[] keywords)
		{
			bool flag = false;
			for (int i = 0; i < keywords.Length; i++)
			{
				string keyword = keywords[i];
				bool flag2 = string.IsNullOrEmpty(keyword);
				if (!flag2)
				{
					bool flag3 = Enumerable.Any<SAKeyword>(this.keywordList, (SAKeyword item) => item.name.Equals(keyword));
					bool flag4 = !flag3;
					if (flag4)
					{
						SAKeyword item2 = new SAKeyword(keyword, null);
						this.keywordList.Add(item2);
						flag = true;
					}
				}
			}
			bool flag5 = flag;
			if (flag5)
			{
				this.keywordList.Sort((SAKeyword keyword1, SAKeyword keyword2) => keyword1.name.CompareTo(keyword2.name));
			}
		}

		// Token: 0x06000D65 RID: 3429 RVA: 0x0003B920 File Offset: 0x00039B20
		public bool IdentifyShaderLength()
		{
			return this.path.Length > 0;
		}

		// Token: 0x06000D66 RID: 3430 RVA: 0x00006D78 File Offset: 0x00004F78
		private void ProcessShaderPassList()
		{
			this.shaderPassList.ForEach(delegate(SAShaderPass shaderPass)
			{
				this.AddKeywordsFromShaderPass(shaderPass);
			});
		}

		// Token: 0x06000D67 RID: 3431 RVA: 0x0003B940 File Offset: 0x00039B40
		private void AddKeywordsFromShaderPass(SAShaderPass shaderPass)
		{
			for (int i = 0; i < shaderPass.keywordLines.Count; i++)
			{
				SAKeywordLine sakeywordLine = shaderPass.keywordLines[i];
				for (int j = 0; j < sakeywordLine.keywords.Count; j++)
				{
					SAKeyword item = sakeywordLine.keywords[j];
					bool flag = !this.keywordList.Contains(item);
					if (flag)
					{
						this.keywordList.Add(item);
					}
				}
			}
		}

		// Token: 0x06000D68 RID: 3432 RVA: 0x00006D93 File Offset: 0x00004F93
		public void ProcessKeywordLines()
		{
			this.shaderPassList.ForEach(delegate(SAShaderPass shaderPass)
			{
				for (int i = 0; i < shaderPass.keywordLines.Count; i++)
				{
					SAKeywordLine sakeywordLine = shaderPass.keywordLines[i];
					int num = sakeywordLine.hasUnderscoreVariant ? 1 : 0;
					int num2 = num + sakeywordLine.keywords.Count;
					HashSet<string> hashSet;
					switch (sakeywordLine.pragmaType)
					{
					case PragmaType.MultiCompileGlobal:
						hashSet = this.globalMultiCompileSet;
						break;
					case PragmaType.MultiCompileLocal:
						hashSet = this.localMultiCompileSet;
						break;
					case PragmaType.FeatureGlobal:
						hashSet = this.globalFeatureSet;
						break;
					case PragmaType.FeatureLocal:
						hashSet = this.localFeatureSet;
						break;
					default:
						throw new Exception("Invalid PragmaType in keyword line.");
					}
					for (int j = 0; j < sakeywordLine.keywords.Count; j++)
					{
						string name = sakeywordLine.keywords[j].name;
						bool flag = !hashSet.Contains(name);
						if (flag)
						{
							hashSet.Add(name);
						}
					}
				}
			});
		}

		// Token: 0x06000D69 RID: 3433 RVA: 0x0003B9C8 File Offset: 0x00039BC8
		public SAKeyword GetKeywordByName(string string_2)
		{
			int count = this.keywordList.Count;
			for (int i = 0; i < count; i++)
			{
				SAKeyword sakeyword = this.keywordList[i];
				bool flag = sakeyword.name.Equals(string_2);
				if (flag)
				{
					return sakeyword;
				}
			}
			return new SAKeyword(string_2, null);
		}

		// Token: 0x06000D6A RID: 3434 RVA: 0x0003BA28 File Offset: 0x00039C28
		public static string GetShaderName(string shaderPath)
		{
			int num = shaderPath.LastIndexOf("/");
			bool flag = num >= 0;
			string result;
			if (flag)
			{
				result = shaderPath.Substring(num + 1);
			}
			else
			{
				result = shaderPath;
			}
			return result;
		}

		// Token: 0x0400082D RID: 2093
		public string shaderName = "";

		// Token: 0x0400082E RID: 2094
		public string string_1 = "";

		// Token: 0x0400082F RID: 2095
		public string path = "";

		// Token: 0x04000830 RID: 2096
		public List<SAShaderPass> shaderPassList = new List<SAShaderPass>();

		// Token: 0x04000831 RID: 2097
		public List<SAKeyword> keywordList = new List<SAKeyword>();

		// Token: 0x04000832 RID: 2098
		public HashSet<string> globalFeatureSet = new HashSet<string>();

		// Token: 0x04000833 RID: 2099
		public HashSet<string> localFeatureSet = new HashSet<string>();

		// Token: 0x04000834 RID: 2100
		public HashSet<string> globalMultiCompileSet = new HashSet<string>();

		// Token: 0x04000835 RID: 2101
		public HashSet<string> localMultiCompileSet = new HashSet<string>();

		// Token: 0x04000836 RID: 2102
		public int int_0;

		// Token: 0x04000837 RID: 2103
		public bool bool_0;

		// Token: 0x04000838 RID: 2104
		public bool bool_1;

		// Token: 0x04000839 RID: 2105
		public bool bool_2;

		// Token: 0x0400083A RID: 2106
		public bool bool_3;

		// Token: 0x0400083B RID: 2107
		public bool bool_4;

		// Token: 0x0400083C RID: 2108
		public bool isGraphShader;
	}
}
